package com.lanou3g.ssoserver.web;

import com.lanou3g.ssoserver.bean.UserInfo;
import com.lanou3g.ssoserver.service.LoginService;
import com.lanou3g.ssoserver.utils.SSOResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;

@RestController
public class LoginController {

    @Autowired
    private LoginService loginService;

    @RequestMapping("/login")
    public SSOResult login(@RequestParam String username, @RequestParam String password, HttpServletResponse resp) {
        return loginService.login(username, password, resp);
    }

    @RequestMapping("/get_user_by_token/{token}")
    public UserInfo getUserByToken(@PathVariable String token) {
        return loginService.getUserByToken(token);
    }

}
